﻿--   WarlockBasic 0.01       --
--	 Written by CN1 BattleGroup1 WoWer  --

--reference
--SetPoint: --point(anchor), relativeFrame, relativePoint, ofsx, ofsy
--Frame:SetBackdrop( { 
 -- bgFile = "bgFile", 
 -- edgeFile = "edgeFile", tile = false, tileSize = 0, edgeSize = 32, 
 -- insets = { left = 0, right = 0, top = 0, bottom = 0 }
--});

--INVSLOT_TRINKET1 = 13
--INVSLOT_TRINKET2 = 14
-- UnitPower: SPELL_POWER_MANA-0, SPELL_POWER_SOUL_SHARDS-7, SPELL_POWER_BURNING_EMBERS-14, SPELL_POWER_DEMONIC_FURY-15

WarlockBasicSetting =
{
	enable = true,
	trinket13 =
	{
		spell_id = 0,
		icon = ""
	},
	trinket14 =
	{
		spell_id = 0,
		icon = ""
	},
};

local Font0 = GameFontHighlight:GetFont();
local Font1 = GameFontNormalSmall:GetFont();
local Font2 = NumberFontNormalSmallGray:GetFont();

local IconSize = 22;
local WhiteTex8x8 = "Interface\\Buttons\\WHITE8x8";
local WndWidth = 180;
local WndHeight = 200;
local SoulShardsBarWidth = (WndWidth - 10 - 10 * 3) / 4;

local SpellInfos =
{
	--afflication
	tongchu =
	{
		spell_id =  980,
		icon = "Interface\\Icons\\Spell_Shadow_CurseOfSargeras"
	},
	fushishu =
	{
		spell_id =  172,
		icon = "Interface\\Icons\\Spell_Shadow_AbominationExplosion"
	},
	tongkuwuchang =
	{
		spell_id = 30108,
		icon = "Interface\\Icons\\Spell_Shadow_UnstableAffliction_3"
	},
	guiyingchanshen =
	{
		spell_id = 48181,
		icon = "Interface\\Icons\\Ability_Warlock_Haunt"
	},
	
	--demonology
	anyinglieyan =
	{
		spell_id = 47960,
		icon = "Interface\\Icons\\Spell_Fire_TwilightFlameBreath"
	},
	morijianglin =
	{
		spell_id = 603,
		icon = "Interface\\Icons\\Spell_Shadow_AuraOfDarkness"
	},
	
	--destruction
	xianji =
	{
		spell_id = 348,
		icon = "Interface\\Icons\\Spell_Fire_Immolation";
	}
};

local function StringSplit(s, p)
    local rt = {};
    string.gsub(s, '[^'..p..']+', function(w)
		table.insert(rt, w)
	end);
    return rt;
end

local function WarlockBasic_CreateFrameBorder(parent, r, g, b, a, size, br, bg, bb, ba)
	local frameBorder = CreateFrame("Frame", nil, parent);
	frameBorder:SetFrameLevel(parent:GetFrameLevel() - 1);
	frameBorder:SetBackdrop(
	{
		bgFile = WhiteTex8x8,
		edgeFile = "Interface\\AddOns\\WarlockBasic\\texture\\glow",
		edgeSize = size,
		insets =
		{
			left = size,
			right = size,
			top = size,
			bottom = size
		}
	});
	frameBorder:SetPoint("TOPLEFT", parent, -size, size);
	frameBorder:SetPoint("BOTTOMRIGHT", parent, size, -size);
	frameBorder:SetBackdropColor(r, g, b, a);
	frameBorder:SetBackdropBorderColor(br, bg, bb, ba or 1);
	parent.frameBorder = frameBorder;
end

local function WarlockBasic_CreateStatusbar(parent, tex, layer, width, height, r, g, b, alpha)
    local bar = CreateFrame("StatusBar");
    bar:SetParent(parent);
	bar:SetFrameLevel(parent:GetFrameLevel() - 1);
	bar:SetSize(width, height);
    bar:SetStatusBarTexture(tex, layer);
    bar:SetStatusBarColor(r, g, b, alpha);
    return bar;
end

local function WarlockBasic_CreateBuffDebuffIcon(parent, level, size, tex, r, g, b)
	local icon = CreateFrame("Frame", nil, parent);
	icon:SetFrameLevel(level);
	icon:SetSize(size, size);
	
	icon.texture = icon:CreateTexture(nil, "BORDER");
	icon.texture:SetAllPoints();
	icon.texture:SetTexture(tex);
	icon.texture:SetTexCoord(0.1, 0.9, 0.1, 0.9);
	
	icon.count = icon:CreateFontString(nil, "OVERLAY");
	icon.count:SetFont(Font2, 10, "OUTLINE");
	icon.count:SetPoint("BOTTOMRIGHT");
	icon.count:SetTextColor(0, 1, 1);
	
	icon.progressbar = WarlockBasic_CreateStatusbar(icon, WhiteTex8x8, nil, WndWidth - IconSize - 15, IconSize, 1, 1, 1, 0.5);
	icon.progressbar:SetPoint("LEFT", icon.texture, "RIGHT", 5, 0);
	icon.progressbar:SetMinMaxValues(0.0, 1.0);
	
	icon.progressbar_bg = WarlockBasic_CreateStatusbar(icon, WhiteTex8x8, nil, WndWidth - IconSize - 15, IconSize, 1, 1, 1, 0.2);
	icon.progressbar_bg:SetPoint("LEFT", icon.texture, "RIGHT", 5, 0);
	
	icon.spell_name = icon:CreateFontString(nil, "OVERLAY");
	icon.spell_name:SetFont(Font1, 12, "OUTLINE");
	icon.spell_name:SetPoint("BOTTOMLEFT", icon.progressbar, "BOTTOMLEFT", 5, 5);
	icon.spell_name:SetTextColor(1, 1, 1);
	
	icon.time_left = icon:CreateFontString(nil, "OVERLAY");
	icon.time_left:SetFont(Font2, 12, "OUTLINE");
	icon.time_left:SetPoint("BOTTOMRIGHT", icon.progressbar, "BOTTOMRIGHT", 0, 5);
	icon.time_left:SetTextColor(r, g, b);
	
	WarlockBasic_CreateFrameBorder(icon, 0, 0, 0, 0, 3, 0, 0, 0);
	return icon;
end

local function UpdateBufferDebuffIcon(self, icon, spell_id, glow)
	if not self.ExpirationTimes[spell_id] then
		return;
	end
	
	local timeLeft = self.ExpirationTimes[spell_id] - GetTime();
	if timeLeft > 0 then
		icon.spell_name:SetText(self.SpellNames[spell_id]);
		icon.progressbar:SetValue(timeLeft / self.Durations[spell_id]);
		icon.time_left:SetText(string.format("%.1f", timeLeft));
		icon.time_left:Show();
		if glow then
			ActionButton_ShowOverlayGlow(icon);
		end
	else
		icon.spell_name:SetText("");
		icon.progressbar:SetValue(0.0);
		icon.time_left:Hide();
		if glow then
			ActionButton_HideOverlayGlow(icon);
		end
	end
	
	if icon == self.TongchuIcon then
		if self.TongchuCount > 0 then
			self.TongchuIcon.count:SetText(self.TongchuCount);
			self.TongchuIcon.count:Show();
		else
			self.TongchuIcon.count:Hide();
		end
	end
end

local function UpdateTargetDebuffs(self)		
	if UnitIsDead("target") then
		self.FushishuIcon.time_left:Hide();
		return;
	end
	
	-- 痛楚/暗影烈焰
	if self.CurSpecialization == 1 then -- afflication
		UpdateBufferDebuffIcon(self, self.TongchuIcon, SpellInfos.tongchu.spell_id, false);
	elseif self.CurSpecialization == 2 then -- demonology
		UpdateBufferDebuffIcon(self, self.TongchuIcon, SpellInfos.anyinglieyan.spell_id, false);
	elseif self.CurSpecialization == 3 then -- destruction
	
	end
	
	-- 腐蚀术/献祭
	if self.CurSpecialization == 1 or self.CurSpecialization == 2 then -- afflication/demonology
		UpdateBufferDebuffIcon(self, self.FushishuIcon, SpellInfos.fushishu.spell_id, false);
	elseif self.CurSpecialization == 3 then -- destruction
		UpdateBufferDebuffIcon(self, self.FushishuIcon, SpellInfos.xianji.spell_id, false);
	end
	
	-- 痛苦无常/末日降临
	if self.CurSpecialization == 1 then -- afflication
		UpdateBufferDebuffIcon(self, self.TongkuwuchangIcon, SpellInfos.tongkuwuchang.spell_id, false);
	elseif self.CurSpecialization == 2 then -- demonology
		UpdateBufferDebuffIcon(self, self.TongkuwuchangIcon, SpellInfos.morijianglin.spell_id, false);
	elseif self.CurSpecialization == 3 then -- destruction
	
	end
	
	-- 鬼影缠身
	if self.CurSpecialization == 1 then -- afflication
		UpdateBufferDebuffIcon(self, self.GuiyingchanshenIcon, SpellInfos.guiyingchanshen.spell_id, false);
	end
	
	-- 饰品13
	if self.ExpirationTimes[WarlockBasicSetting.trinket13.spell_id] then
		if self.TrinketIcon13.texture:GetTexture() ~= WarlockBasicSetting.trinket13.icon then
			self.TrinketIcon13.texture:SetTexture(WarlockBasicSetting.trinket13.icon);
		end
		
		UpdateBufferDebuffIcon(self, self.TrinketIcon13, WarlockBasicSetting.trinket13.spell_id, true);
	end
	
	-- 饰品14
	if self.ExpirationTimes[WarlockBasicSetting.trinket14.spell_id] then
		if self.TrinketIcon14.texture:GetTexture() ~= WarlockBasicSetting.trinket14.icon then
			self.TrinketIcon14.texture:SetTexture(WarlockBasicSetting.trinket14.icon);
		end
		
		UpdateBufferDebuffIcon(self, self.TrinketIcon14, WarlockBasicSetting.trinket14.spell_id, true);
	end
end

local function UpdateSpellInfo_Buff_Trinkets(self, spell_id)
	local spell_name = GetSpellInfo(spell_id);
	if not spell_name then
		return;
	end
	
	local name, _, icon, _, _, duration, expirationTime = UnitBuff("player", spell_name);
	if not name then
		self.SpellNames[spell_id] = "";
		self.Durations[spell_id] = 1;
		self.ExpirationTimes[spell_id] = GetTime();
	else
		if spell_id == WarlockBasicSetting.trinket13.spell_id and WarlockBasicSetting.trinket13.icon ~= icon then
			WarlockBasicSetting.trinket13.icon = icon;
		end
		if spell_id == WarlockBasicSetting.trinket14.spell_id and WarlockBasicSetting.trinket14.icon ~= icon then
			WarlockBasicSetting.trinket14.icon = icon;
		end
	
		self.SpellNames[spell_id] = name;
		self.Durations[spell_id] = duration;
		self.ExpirationTimes[spell_id] = expirationTime;
	end
end

local function UpdateSpellInfo_Debuff(self, spell_id)
	local spell_name = GetSpellInfo(spell_id);
	local name, _, _, count, _, duration, expirationTime, unitCaster = UnitDebuff("target", spell_name);	
	if not name or unitCaster ~= "player" then
		self.SpellNames[spell_id] = "";
		self.Durations[spell_id] = 0.001;
		
		self.ExpirationTimes[spell_id] = GetTime();
		if spell_id == SpellInfos.tongchu.spell_id then
			self.TongchuCount = 0;
		end
	else
		self.SpellNames[spell_id] = name;
		self.Durations[spell_id] = duration;
		self.ExpirationTimes[spell_id] = expirationTime;
		
		if spell_id == SpellInfos.tongchu.spell_id then
			self.TongchuCount = count;
		end
	end
end

local function UpdateLayoutBySpecialization(self)
	if self.CurSpecialization == 1 then -- afflication
		self.TongchuIcon.texture:SetTexture(SpellInfos.tongchu.icon);
		self.TongkuwuchangIcon.texture:SetTexture(SpellInfos.tongkuwuchang.icon);
		
		self.TrinketIcon13:SetPoint("TOPLEFT", self.GuiyingchanshenIcon, "BOTTOMLEFT", 0, -5);
		self:SetHeight(WndHeight);
		
		self.TongchuIcon:Show();
		self.TongkuwuchangIcon:Show();
		self.GuiyingchanshenIcon:Show();
	elseif self.CurSpecialization == 2 then -- demonology
		self.TongchuIcon.texture:SetTexture(SpellInfos.anyinglieyan.icon);
		self.TongkuwuchangIcon.texture:SetTexture(SpellInfos.morijianglin.icon);
		
		self.TrinketIcon13:SetPoint("TOPLEFT", self.TongkuwuchangIcon, "BOTTOMLEFT", 0, -5);
		self:SetHeight(WndHeight - IconSize * 2 + 15);
		
		self.GuiyingchanshenIcon:Hide();
	elseif self.CurSpecialization == 3 then -- destruction
		self.FushishuIcon.texture:SetTexture(SpellInfos.xianji.icon);
		self.FushishuIcon:SetPoint("TOPLEFT", self.DemonicFuryBar, "BOTTOMLEFT", 0, -5);
		
		self.TrinketIcon13:SetPoint("TOPLEFT", self.FushishuIcon, "BOTTOMLEFT", 0, -5);
		self:SetHeight(WndHeight - IconSize * 4 + 5);
		
		self.TongchuIcon:Hide();
		self.TongkuwuchangIcon:Hide();
		self.GuiyingchanshenIcon:Hide();
	end
end

local function WarlockBasic_OnEvent(self, event, unit, arg2)
	if (event == "PLAYER_ENTERING_WORLD") then
		local _, _, clsIdx = UnitClass("player");
		if clsIdx == 9 then
			self:Show();
			self.CurSpecialization = GetSpecialization();
			UpdateLayoutBySpecialization(self);
		else
			self:Hide();
		end
	end
	
	if event == "PLAYER_TALENT_UPDATE" then
		self.CurSpecialization = GetSpecialization();
		UpdateLayoutBySpecialization(self);
	end
	
	if event == "UNIT_AURA" or event == "PLAYER_TARGET_CHANGED" then	
		if self.CurSpecialization == 1 then -- afflication
			UpdateSpellInfo_Debuff(self, SpellInfos.tongchu.spell_id);
			UpdateSpellInfo_Debuff(self, SpellInfos.fushishu.spell_id);
			UpdateSpellInfo_Debuff(self, SpellInfos.tongkuwuchang.spell_id);
			UpdateSpellInfo_Debuff(self, SpellInfos.guiyingchanshen.spell_id);
		elseif self.CurSpecialization == 2 then -- demonology
			UpdateSpellInfo_Debuff(self, SpellInfos.anyinglieyan.spell_id);
			UpdateSpellInfo_Debuff(self, SpellInfos.fushishu.spell_id);
			UpdateSpellInfo_Debuff(self, SpellInfos.morijianglin.spell_id);
		elseif self.CurSpecialization == 3 then -- destruction
			UpdateSpellInfo_Debuff(self, SpellInfos.xianji.spell_id);
		end
		
		UpdateSpellInfo_Buff_Trinkets(self, WarlockBasicSetting.trinket13.spell_id);
		UpdateSpellInfo_Buff_Trinkets(self, WarlockBasicSetting.trinket14.spell_id);
	end
end

local function WarlockBasic_OnUpdate(self, elapsed)
	self.TimeSinceLastUpdate = self.TimeSinceLastUpdate + elapsed;
	if (self.TimeSinceLastUpdate > 1.0) then
		--update hp
		local hp = UnitHealth("player");
		local ratio = hp / UnitHealthMax("player");
		self.HPBar:SetValue(ratio);
		
		--update mp
		local mp = UnitPower("player", 0);
		ratio = mp / UnitManaMax("player");
		self.MPBar:SetValue(ratio);
		
		if self.CurSpecialization == 1 or self.CurSpecialization == 3 then -- afflication/destruction
			--update soul shards/burning embers
			local n = 0;
			if self.CurSpecialization == 1 then
				n = UnitPower("player", 7);
			else
				n = UnitPower("player", 14);
			end
			
			for key, value in pairs(self.SoulShardsIcons) do
				if self.CurSpecialization == 1 then
					value:SetStatusBarColor(1, 0, 1); --pink
				else
					value:SetStatusBarColor(0.95, 0.63, 0.12); --yellow
				end
				
				if key <= n then
					value:Show();
				else
					value:Hide();
				end
			end
			
			self.DemonicFuryBar:Hide();
		elseif self.CurSpecialization == 2 then -- demonology
			--update demonic fury
			local df = UnitPower("player", 15);
			ratio = df / 1000.0;
			
			for key, value in pairs(self.SoulShardsIcons) do
				value:Hide();
			end
		
			self.DemonicFuryBar:SetValue(ratio);
			self.DemonicFuryBar:Show();			
		end
		
		self.TimeSinceLastUpdate = 0;
	end
	
	UpdateTargetDebuffs(self);
end

local function SlashCommandHandler(msg)	
	local params = StringSplit(msg, ",");
	if not params[1] or not params[2] then
		print("错误的参数，正确的格式是: /wb 13 饰品触发的法术id, 13是指第1个饰品，14是第2个饰品, 如 /wb 13,111  /wb 14,222");
		return;
	end
	
	local idx = tonumber(params[1]);
	if idx == 13 then
		WarlockBasicSetting.trinket13.spell_id = params[2];
		print("第1个饰品已添加到饰品触发监控中, 饰品id是: " .. params[2]);
	end
	if idx == 14 then
		WarlockBasicSetting.trinket14.spell_id = params[2];
		print("第2个饰品已添加到饰品触发监控中, 饰品id是: " .. params[2]);
	end
end

local WarlockBasic = CreateFrame("Frame", "WarlockBasic", UIParent);
WarlockBasic:SetMovable(true);
WarlockBasic:EnableMouse(true);
WarlockBasic:RegisterForDrag("LeftButton");
WarlockBasic:SetPoint("CENTER", UIParent, "CENTER", 0, 0);
WarlockBasic:SetSize(WndWidth, WndHeight);
WarlockBasic_CreateFrameBorder(WarlockBasic, 0, 0, 0, 0, 3, 0, 0, 0);

WarlockBasic:SetScript("OnDragStart", WarlockBasic.StartMoving);
WarlockBasic:SetScript("OnDragStop", WarlockBasic.StopMovingOrSizing);
WarlockBasic:SetScript("OnEvent", WarlockBasic_OnEvent);
WarlockBasic:SetScript("OnUpdate", WarlockBasic_OnUpdate);

WarlockBasic.HPBar = WarlockBasic_CreateStatusbar(WarlockBasic, WhiteTex8x8, nil, WndWidth - 10, 8, 1, 0, 0, 0.5);
WarlockBasic.HPBar:SetPoint("TOPLEFT", WarlockBasic, "TOPLEFT", 5, -3);
WarlockBasic.HPBar:SetMinMaxValues(0.0, 1.0);

WarlockBasic.MPBar = WarlockBasic_CreateStatusbar(WarlockBasic, WhiteTex8x8, nil, WndWidth - 10, 8, 0, 0, 1, 0.5);
WarlockBasic.MPBar:SetPoint("TOPLEFT", WarlockBasic.HPBar, "BOTTOMLEFT", 0, -3);
WarlockBasic.MPBar:SetMinMaxValues(0.0, 1.0);

WarlockBasic.SoulShardsIcons = {};
WarlockBasic.SoulShardsIcons[1] = WarlockBasic_CreateStatusbar(WarlockBasic, WhiteTex8x8, nil, SoulShardsBarWidth, 8, 1, 0, 1, 1);
WarlockBasic.SoulShardsIcons[1]:SetPoint("TOPLEFT", WarlockBasic.MPBar, "BOTTOMLEFT", 0, -3);

WarlockBasic.SoulShardsIcons[2] = WarlockBasic_CreateStatusbar(WarlockBasic, WhiteTex8x8, nil, SoulShardsBarWidth, 8, 1, 0, 1, 1);
WarlockBasic.SoulShardsIcons[2]:SetPoint("LEFT", WarlockBasic.SoulShardsIcons[1], "RIGHT", 10, 0);

WarlockBasic.SoulShardsIcons[3] = WarlockBasic_CreateStatusbar(WarlockBasic, WhiteTex8x8, nil, SoulShardsBarWidth, 8, 1, 0, 1, 1);
WarlockBasic.SoulShardsIcons[3]:SetPoint("LEFT", WarlockBasic.SoulShardsIcons[2], "RIGHT", 10, 0);

WarlockBasic.SoulShardsIcons[4] = WarlockBasic_CreateStatusbar(WarlockBasic, WhiteTex8x8, nil, SoulShardsBarWidth, 8, 1, 0, 1, 1);
WarlockBasic.SoulShardsIcons[4]:SetPoint("LEFT", WarlockBasic.SoulShardsIcons[3], "RIGHT", 10, 0);

WarlockBasic.DemonicFuryBar = WarlockBasic_CreateStatusbar(WarlockBasic, WhiteTex8x8, nil, WndWidth - 10, 8, 0.52, 0.21, 0.78, 1);
WarlockBasic.DemonicFuryBar:SetPoint("TOPLEFT", WarlockBasic.MPBar, "BOTTOMLEFT", 0, -3);
WarlockBasic.DemonicFuryBar:SetMinMaxValues(0.0, 1.0);

WarlockBasic.TongchuIcon = WarlockBasic_CreateBuffDebuffIcon(WarlockBasic, 3, IconSize, SpellInfos.tongchu.icon, 1, 1, 1);
WarlockBasic.TongchuIcon:SetPoint("TOPLEFT", WarlockBasic.DemonicFuryBar, "BOTTOMLEFT", 0, -5);
WarlockBasic.TongchuIcon.time_left:Hide();

WarlockBasic.FushishuIcon = WarlockBasic_CreateBuffDebuffIcon(WarlockBasic, 3, IconSize, SpellInfos.fushishu.icon, 1, 1, 1);
WarlockBasic.FushishuIcon:SetPoint("TOPLEFT", WarlockBasic.TongchuIcon, "BOTTOMLEFT", 0, -5);
WarlockBasic.FushishuIcon.time_left:Hide();

WarlockBasic.TongkuwuchangIcon = WarlockBasic_CreateBuffDebuffIcon(WarlockBasic, 3, IconSize, SpellInfos.tongkuwuchang.icon, 1, 1, 1);
WarlockBasic.TongkuwuchangIcon:SetPoint("TOPLEFT", WarlockBasic.FushishuIcon, "BOTTOMLEFT", 0, -5);
WarlockBasic.TongkuwuchangIcon.time_left:Hide();

WarlockBasic.GuiyingchanshenIcon = WarlockBasic_CreateBuffDebuffIcon(WarlockBasic, 3, IconSize, SpellInfos.guiyingchanshen.icon, 1, 1, 1);
WarlockBasic.GuiyingchanshenIcon:SetPoint("TOPLEFT", WarlockBasic.TongkuwuchangIcon, "BOTTOMLEFT", 0, -5);
WarlockBasic.GuiyingchanshenIcon.time_left:Hide();

WarlockBasic.TrinketIcon13 = WarlockBasic_CreateBuffDebuffIcon(WarlockBasic, 3, IconSize, "", 1, 1, 1);
WarlockBasic.TrinketIcon13:SetPoint("TOPLEFT", WarlockBasic.GuiyingchanshenIcon, "BOTTOMLEFT", 0, -5);
WarlockBasic.TrinketIcon13.time_left:Hide();

WarlockBasic.TrinketIcon14 = WarlockBasic_CreateBuffDebuffIcon(WarlockBasic, 3, IconSize, "", 1, 1, 1);
WarlockBasic.TrinketIcon14:SetPoint("TOPLEFT", WarlockBasic.TrinketIcon13, "BOTTOMLEFT", 0, -5);
WarlockBasic.TrinketIcon14.time_left:Hide();

WarlockBasic:RegisterEvent("PLAYER_ENTERING_WORLD");
WarlockBasic:RegisterEvent("PLAYER_TARGET_CHANGED");
WarlockBasic:RegisterEvent("PLAYER_TALENT_UPDATE");
WarlockBasic:RegisterEvent("UNIT_AURA");

WarlockBasic.CurSpecialization = 0;
WarlockBasic.TimeSinceLastUpdate = 0.0;
WarlockBasic.TongchuCount = 0;
WarlockBasic.SpellNames = {};
WarlockBasic.Durations = {};
WarlockBasic.ExpirationTimes = {};

WarlockBasic.SpellNames[SpellInfos.tongchu.spell_id] = "";
WarlockBasic.SpellNames[SpellInfos.fushishu.spell_id] = "";
WarlockBasic.SpellNames[SpellInfos.tongkuwuchang.spell_id] = "";
WarlockBasic.SpellNames[SpellInfos.guiyingchanshen.spell_id] = "";

WarlockBasic.Durations[SpellInfos.tongchu.spell_id] = 0.001;
WarlockBasic.Durations[SpellInfos.fushishu.spell_id] = 0.001;
WarlockBasic.Durations[SpellInfos.tongkuwuchang.spell_id] = 0.001;
WarlockBasic.Durations[SpellInfos.guiyingchanshen.spell_id] = 0.001;

WarlockBasic.ExpirationTimes[SpellInfos.tongchu.spell_id] = GetTime();
WarlockBasic.ExpirationTimes[SpellInfos.fushishu.spell_id] = GetTime();
WarlockBasic.ExpirationTimes[SpellInfos.tongkuwuchang.spell_id] = GetTime();
WarlockBasic.ExpirationTimes[SpellInfos.guiyingchanshen.spell_id] = GetTime();

--local itemid = GetInventoryItemID("player", 13);
--local isname, isrank = GetItemSpell(itemid);
--print(isname);

SLASH_WARLOCKBASIC1 = "/warlockbasic";
SLASH_WARLOCKBASIC2 = "/wb";
SlashCmdList["WARLOCKBASIC"] = SlashCommandHandler;
